const BaseDataAdapter = require('./../../base-data-adapter');
const projectVersions = require('./../../../project-versions');
const files = require('./../../../files');
const functions = require('./../../../functions');

class DefaultDataAdapter extends BaseDataAdapter {
  async getTestResultOverview(versionId) {
    return projectVersions.testResultOverview(versionId);
  }

  async getFilesOverview(versionId, extensions) {
    return Promise.all([
      files.getOverview(versionId, {
        extensions,
        pageSize: 999999,
      }),
      files.fileCountOverview(versionId, { extensions }),
    ])
      .then(([[filesOverview], fileStatusCount]) => ({ filesOverview, fileStatusCount }));
  }

  async getFunctionsOverview(versionId) {
    return functions.getOverview(versionId, { pageSize: 999999 })
      .then(([functionsOverview]) => functionsOverview);
  }

  async getFunctionCoverageDistribution(versionId) {
    return projectVersions.functionCoverageDistribution(versionId);
  }

  async getVersionOverview(versionId) {
    return projectVersions.getOverview(versionId);
  }
}

module.exports = DefaultDataAdapter;
